﻿ 
<%@ page contentType="text/html; charset=UTF-8" %>

 

<div class="searchBar">

查询条件：<input id="s_sytedemo_name" name="s_sytedemo_name" type="text" class="box-input">&nbsp;&nbsp;
<input id="s_sytedemo" type="button" class="btns" value="查  询">
</div>

<table id="sytedemo_grid"></table>      
<div id="sytedemo_page"></div>  

<div id="sytedemo_dialog_index" title="新增sytedemo">
<form id="sytedemo_form_index" name="sytedemo_form_index" style="width:326px;" class="cmxform" method="POST">
    <div id="sytedemo_index_errmsg"></div>
    <table width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="jkt-tableStyle">

	<tr>
        <td class="bluetd" align="right">名称：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_name_index" name="sytedemo_name_index" />
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">操作员ID：</td>
        <td class="bluetd2" align="left">
          <input id="sytedemo_userId_index" name="sytedemo_userId_index" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">是否有效：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_valid_index" name="sytedemo_valid_index" />
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">int数字：</td>
        <td class="bluetd2" align="left">
          <input id="sytedemo_number_index" name="sytedemo_number_index" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">URL地址：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_url_index" name="sytedemo_url_index" />
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">Email：</td>
        <td class="bluetd2" align="left">
          <input id="sytedemo_email_index" name="sytedemo_email_index" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">变长字符集大对象：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_textDemo_index" name="sytedemo_textDemo_index" />
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">变长二进制大对象：</td>
        <td class="bluetd2" align="left">
          <input id="sytedemo_blobDemo_index" name="sytedemo_blobDemo_index" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">varchar示例：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_varcharDemo_index" name="sytedemo_varcharDemo_index" />
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">日期示例：</td>
        <td class="bluetd2" align="left">
          <input id="sytedemo_dateDemo_index" name="sytedemo_dateDemo_index" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">DATETIME示例：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_datetimeDemo_index" name="sytedemo_datetimeDemo_index" />
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">TIMESTAMP示例：</td>
        <td class="bluetd2" align="left">
          <input id="sytedemo_timestampDemo_index" name="sytedemo_timestampDemo_index" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">FLOAT示例：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_floatDemo_index" name="sytedemo_floatDemo_index" />
        </td>
     </tr>     <tr>
        <td class="bluetd2" align="right">上级节点ID：</td>
        <td class="bluetd2" align="left">
          <input id="sytedemo_parentId_index" name="sytedemo_parentId_index" />
        </td>
     </tr>
	<tr>
        <td class="bluetd" align="right">创建时间：</td>
        <td class="bluetd" align="left">
          <input id="sytedemo_createTime_index" name="sytedemo_createTime_index" />
        </td>
     </tr>
      <tr>
        <td colspan="2" align="center">
         <input type="button" class="btns" id="sytedemo_index_bt" value="提  交" style="margin-top:8px;" />&nbsp;&nbsp;
         <input type="button" class="btns" id="sytedemo_close" value="关  闭" style="margin-top:8px;" />
      </td>
</tr>
</table>
</form>
</div> 
<script>
var sytedemoJson1="{'userId':'1','name':'3' }";
	$.ajax({
            type: "POST",
            url:"barapp/SyteDemo/findListByBean.do",
            dataType: "json",
            data:{
            	 sytedemoJson:sytedemoJson1,
            	 number:"5",
            	valid:"20"
            },
            success:function(json){
            	alertmsg("OK","alert");
            }
    })
</script>
<script>

    var sytedemovalidate,sytedemoids='',sytedemosave=true;//本页面变量
    
	jQuery("#sytedemo_grid").jqGrid({//列表
        datatype: "json", //JSON格式数据
        hidegrid: false, //不显示收缩
        url:'barapp/SyteDemo/list.do', //请求后台返回列表数据的URL 
        forceFit: false,//调整宽度不改变表格宽度
        width: "100%",
        height: "100%",
        colNames:[
        '编号'
        ,'名称'
        ,'操作员ID'
        ,'是否有效'
        ,'int数字'
        ,'URL地址'
        ,'Email'
        ,'变长字符集大对象'
        ,'变长二进制大对象'
        ,'varchar示例'
        ,'日期示例'
        ,'DATETIME示例'
        ,'TIMESTAMP示例'
        ,'FLOAT示例'
        ,'上级节点ID'
        ,'创建时间'
	    ],
	    //要呈现字段的属性设置
	    //sortable:设置该字段是否进行排序,sorttype:排序的数据类型 
        colModel:[
        {name:'id',index:'id', width:2,sorttype:'int',sortable:false}  
        ,{name:'name',index:'name',width:100,sortable:false}
        ,{name:'userId',index:'userId',width:100,sortable:false}
        ,{name:'valid',index:'valid',width:100,sortable:false}
        ,{name:'number',index:'number',width:100,sortable:false}
        ,{name:'url',index:'url',width:100,sortable:false}
        ,{name:'email',index:'email',width:100,sortable:false}
        ,{name:'textDemo',index:'textDemo',width:100,sortable:false}
        ,{name:'blobDemo',index:'blobDemo',width:100,sortable:false}
        ,{name:'varcharDemo',index:'varcharDemo',width:100,sortable:false}
        ,{name:'dateDemo',index:'dateDemo',width:100,sortable:false}
        ,{name:'datetimeDemo',index:'datetimeDemo',width:100,sortable:false}
        ,{name:'timestampDemo',index:'timestampDemo',width:100,sortable:false}
        ,{name:'floatDemo',index:'floatDemo',width:100,sortable:false}
        ,{name:'parentId',index:'parentId',width:100,sortable:false}
        ,{name:'createTime',index:'createTime',width:100,sortable:false}
        ],
        multiselect: true,//禁止多选
        toolbar:[true,'top'],
        rowNum:10, 
        rowList:[10,20,30,50,100,500], 
        viewrecords: true, 
        sortname:  "id" , //默认排序的列名    //sortorder: "desc", 
        pager: '#sytedemo_page', 
        jsonReader: {     
          root: 'dataRows',   
          repeatitems : false     
        }
    })
    
    $("#t_sytedemo_grid").append("<div style='width:30%;height:30px;' class='l'>sytedemo列表</div><div class='r text-r' style='width:30%; height:30px'>"
       +"<a href='javascript:void(0)' onclick=\"fun_sytedemo_update()\" class='modify r'>修改</a>"
       +"<a href='javascript:void(0)' onclick=\"fun_sytedemo_delete()\" class='del r'>删除</a> "
       +"<a href='javascript:void(0)' onclick=\"fun_sytedemo_add()\" class='add r'>新增</a></div>");//列表头
       
    $("#t_sytedemo_grid").removeClass("ui-userdata ui-state-default"); //删样式
    $("#t_sytedemo_grid").addClass("ui-title ui-corner-top ui-helper-clearfix");//加样式
    
    jQuery("#sytedemo_grid").jqGrid('hideCol',['id']);//隐藏列
    $("#sytedemo_grid").closest(".ui-jqgrid-bdiv").css({ 'overflow-x' : 'hidden' });//隐藏横向滚动条
    
    function fun_sytedemo_add(){//新增操作
		$("#sytedemo_dialog_index").dialog('option' , 'title',['新增sytedemo']);
		$("#sytedemo_form_index")[0].reset();
		sytedemovalidate.resetForm(); //重置验证状态
		$('#sytedemo_index_errmsg').html("");
		$("#sytedemo_dialog_index").dialog("open");
		$("#sytedemo_dialog_index").dialog('option' , 'height',[sytedemoDialogHeight()]);
		sytedemosave=true;
	}
    
    $('#sytedemo_index_bt').click(function(){//点击按妞
         if(rulesByValidator(sytedemovalidate)){
             if(sytedemosave){
                 sytedemo_add_submit();
             }else{
                 sytedemo_update_submit();
             }
         }
     })
     
     //新增提交
     function  sytedemo_add_submit(){
        var sytedemoJson="{'id':'','name':'"+$('#sytedemo_name_index').val()+"','userId':'"+$('#sytedemo_userId_index').val()+"','valid':'"+$('#sytedemo_valid_index').val()+"','number':'"+$('#sytedemo_number_index').val()+"','url':'"+$('#sytedemo_url_index').val()+"','email':'"+$('#sytedemo_email_index').val()+"','textDemo':'"+$('#sytedemo_textDemo_index').val()+"','blobDemo':'"+$('#sytedemo_blobDemo_index').val()+"','varcharDemo':'"+$('#sytedemo_varcharDemo_index').val()+"','dateDemo':'"+$('#sytedemo_dateDemo_index').val()+"','datetimeDemo':'"+$('#sytedemo_datetimeDemo_index').val()+"','timestampDemo':'"+$('#sytedemo_timestampDemo_index').val()+"','floatDemo':'"+$('#sytedemo_floatDemo_index').val()+"','parentId':'"+$('#sytedemo_parentId_index').val()+"','createTime':'"+$('#sytedemo_createTime_index').val()+"'}";  
         $.ajax({
             type: "POST",
             url:"barapp/SyteDemo/save.do",
             data:{
                 sytedemoJson:sytedemoJson
             },
             dataType: "json",
             contentType: "application/x-www-form-urlencoded; charset=UTF-8",
             success:function(json){
                 if(json.success){
                     $("#sytedemo_grid").trigger("reloadGrid");
                     alertmsg(json.msg,"info");
                     sytedemovalidate.resetForm(); //重置验证状态
                 }else{
                     alertmsg(json.msg,"alert");
                 }
             }
         })
     }
     
      //修改提交
     function  sytedemo_update_submit(){
         var sytedemoJson="{'id':'"+rowData.id+"','name':'"+$('#sytedemo_name_index').val()+"','userId':'"+$('#sytedemo_userId_index').val()+"','valid':'"+$('#sytedemo_valid_index').val()+"','number':'"+$('#sytedemo_number_index').val()+"','url':'"+$('#sytedemo_url_index').val()+"','email':'"+$('#sytedemo_email_index').val()+"','textDemo':'"+$('#sytedemo_textDemo_index').val()+"','blobDemo':'"+$('#sytedemo_blobDemo_index').val()+"','varcharDemo':'"+$('#sytedemo_varcharDemo_index').val()+"','dateDemo':'"+$('#sytedemo_dateDemo_index').val()+"','datetimeDemo':'"+$('#sytedemo_datetimeDemo_index').val()+"','timestampDemo':'"+$('#sytedemo_timestampDemo_index').val()+"','floatDemo':'"+$('#sytedemo_floatDemo_index').val()+"','parentId':'"+$('#sytedemo_parentId_index').val()+"','createTime':'"+$('#sytedemo_createTime_index').val()+"'}";  
         $.ajax({
             type: "POST",
             url:"barapp/SyteDemo/update.do",
             data:{
                 sytedemoJson:sytedemoJson
             },
             dataType: "json",
             contentType: "application/x-www-form-urlencoded; charset=UTF-8",
             success:function(json){
                 if(json.success){
                     $("#sytedemo_grid").trigger("reloadGrid");
                     alertmsg(json.msg,"info");
                 }else{
                     alertmsg(json.msg,"alert");
                 }
             }
        })
     }
        
     $('#sytedemo_close').click(function(){//关闭
         $("#sytedemo_dialog_index").dialog('close');
     })
	
	 sytedemovalidate = $("#sytedemo_form_index").validate({//验证
	        errorElement: "div",
            errorPlacement: function(error, element) {
			    $('#sytedemo_index_errmsg').html("");
				error.appendTo( "#sytedemo_index_errmsg" );
				if($.browser.mozilla){//火狐
                    $("#sytedemo_dialog_index").dialog('option' , 'height',[sytedemoDialogHeight()+40]);
	            }else{//其它
		            $("#sytedemo_dialog_index").dialog('option' , 'height',[sytedemoDialogHeight()+50]);
	            }
			},
			success: function(label) {
			    label.text("验证通过!").removeClass("error").addClass("success");
			},
	        rules: {
	            sytedemo_name_index:{
                   required: true
               }
	        }, 
	        messages: {
	            sytedemo_name_index:{
                   required: "name不能为空"
                }
	        },
	        onkeyup:false,
		    onsubmit:false
	});
	
	function fun_sytedemo_delete(){//删除验证
        var data = $("#sytedemo_grid").jqGrid('getGridParam','selarrrow');//'selrow'
        var length=data.length;
        if(length <1){
	        alertmsg("请至少选择一条记录再操作!","alert");
	        return;
	    }
	    sytedemoids='';
	    for(var i=0;i<length;i++){
	        if(i > 0){
                 sytedemoids += ', ';
            }
            sytedemoids += data[i];
	    }
        confirm("确认要删除所选记录吗？", fun_sytedemo_del);
    }
    
    function fun_sytedemo_del(){//删除操作
	    $.ajax({
            type: "POST",
            url:"barapp/SyteDemo/delete.do",
            dataType: "json",
            data:{
                 ids:sytedemoids
            },
            success:function(json){
                 if(json.success){
                      alertmsg(json.msg,"info");
                      $("#sytedemo_grid").trigger("reloadGrid");
                 }else{
                      alertmsg(json.msg,"alert");
                 }
            }
        })
    }
    
    function fun_sytedemo_update(){//修改操作
        var id =$("#sytedemo_grid").jqGrid('getGridParam','selrow');
        if(typeof(id) =="string"){
            rowData=jQuery("#sytedemo_grid").jqGrid('getRowData',id);  
		    $("#sytedemo_dialog_index").dialog('option' , 'title',['修改#sytedemo']);
		    $("#sytedemo_form_index")[0].reset();
		    sytedemovalidate.resetForm(); //重置验证状态
		    $("#sytedemo_dialog_index").dialog("open");
            load_sytedemo_data();
            sytedemosave=false;
        }else{
           alertmsg("请至少选择一条记录再操作!","alert");
        }
	}
	
	function load_sytedemo_data(){//加载数据
         $("#sytedemo_name_index").val(rowData.name);
         $("#sytedemo_userId_index").val(rowData.userId);
         $("#sytedemo_valid_index").val(rowData.valid);
         $("#sytedemo_number_index").val(rowData.number);
         $("#sytedemo_url_index").val(rowData.url);
         $("#sytedemo_email_index").val(rowData.email);
         $("#sytedemo_textDemo_index").val(rowData.textDemo);
         $("#sytedemo_blobDemo_index").val(rowData.blobDemo);
         $("#sytedemo_varcharDemo_index").val(rowData.varcharDemo);
         $("#sytedemo_dateDemo_index").val(rowData.dateDemo);
         $("#sytedemo_datetimeDemo_index").val(rowData.datetimeDemo);
         $("#sytedemo_timestampDemo_index").val(rowData.timestampDemo);
         $("#sytedemo_floatDemo_index").val(rowData.floatDemo);
         $("#sytedemo_parentId_index").val(rowData.parentId);
         $("#sytedemo_createTime_index").val(rowData.createTime);
	}
	
	$("#sytedemo_dialog_index").dialog({//弹出层
		 autoOpen: false,
		 height: sytedemoDialogHeight(),
		 width: 600,
		 modal: true
	});

    function sytedemoDialogHeight(){//弹出层高度
        if($.browser.mozilla){//火狐
           return 410;
	    }else{//其它
		   return 400;
	    }
    }

 
 
	
	//注意:web服务器 utf-8配置
	$('#s_sytedemo').click(function(){
         var s_name=encodeURI($('#s_sytedemo_name').val());
         $("#sytedemo_grid").setGridParam({url:'barapp/SyteDemo/list.do?s_name='+s_name});
         $("#sytedemo_grid").trigger("reloadGrid");
    })
    

     
</script>
